<script>
  document.addEventListener('DOMContentLoaded', () => {
    const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
    if ($navbarBurgers.length > 0) {
      $navbarBurgers.forEach(el => {
        el.addEventListener('click', () => {
          const target = el.dataset.target;
          const $target = document.getElementById(target);
          el.classList.toggle('is-active');
          $target.classList.toggle('is-active');
        });
      });
    }
  });

</script>
<nav id="navbar" class="navbar has-shadow has-background-primary-light">
  <div class="container">
    <div class="navbar-brand">
      <a class="navbar-item" href="#">
        <img src="/img/logo.PNG" alt="logo">
      </a>
      <!-- 可视化汉堡线 -->
      <div class="navbar-burger burger" data-target="navMenu" aria-label="menu" aria-expanded="false">
        <span></span>
        <span></span>
        <span></span>
      </div>
    </div>
    <div id="navMenu" class="navbar-menu">
      <div class="navbar-start">
        <a class="navbar-item" href="/">主页</a>
        <a class="navbar-item" href="https://juejin.cn/user/1407816805127112">掘金首页</a>
        <a class="navbar-item" href="https://gitee.com/wang-mingshun">gitee首页</a>
        <!-- 下拉菜单 -->
        <div class="navbar-item has-dropdown is-hoverable">
          <a class="navbar-link">
            更多
          </a>
          <div class="navbar-dropdown">
            <a class="navbar-item" href="https://juejin.cn/post/6844903976693940231">
              面试题
            </a>
            <a class="navbar-item" href="https://leetcode-cn.com/u/mshun_wang618/">
              力扣
            </a>
            <a class="navbar-item" href="https://www.bulmacss.cn/doc/read/99.html#a1">
              本博客CSS
            </a>
            <!-- <hr class="navbar-divider"> -->
            <a class="navbar-item" href="https://github.com/stephentian/33-js-concepts">
              js概念
            </a>
          </div>
        </div>
      </div>
      <div class="navbar-end">
        {% if ctx.session.user.isAdmin %}
        <div class="navbar-item">
          <a class="button is-small is-primary" href="/category">分类</a>
        </div>
        <div class="navbar-item">
          <a class="button is-small is-primary" href="/posts/new">写文章</a>
        </div>
        {% endif %}
        {% if ctx.session.user %}
        <div class="navbar-item">
          <a href="/" class="has-text-black is-size-5	">{{ctx.session.user.name}}</a>
        </div>
        <div class="navbar-item">
          <a href="/signout">退出</a>
        </div>
        {% else %}
        <div class="navbar-item">
          <a class="button is-small is-primary" href="/signup">注册</a>
        </div>
        <div class="navbar-item">
          <a class="button is-small" href="/signin">登录</a>
        </div>
        {% endif %}
      </div>

    </div>
</nav>
